home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////////////////////
- // $Id: BreakpointList.cxx,v 1.1 1994/02/18 19:49:17 bmott Exp $
- ///////////////////////////////////////////////////////////////////////////////
- // BreakpointList.cxx
- //
- // This class manages a list of breakpoints
- //
- //
- // BSVC "A Microprocessor Simulation Framework"
- // Copyright (c) 1993
- // By: Bradford W. Mott
- // November 23,1993
- //
- ///////////////////////////////////////////////////////////////////////////////
- // $Log: BreakpointList.cxx,v $
- // Revision 1.1 1994/02/18 19:49:17 bmott
- // Initial revision
- //
- ///////////////////////////////////////////////////////////////////////////////
-
- #include "BreakpointList.hxx"
-
- ///////////////////////////////////////////////////////////////////////////////
- // The class constructor
- ///////////////////////////////////////////////////////////////////////////////
- BreakpointList::BreakpointList()
- {
- head=tail=(void*)0;
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // Add a breakpoint to the list
- ///////////////////////////////////////////////////////////////////////////////
- void BreakpointList::Add(unsigned long address)
- {
- BreakpointNode *p;
-
- // If the address is already in the list then just return
- for(p=head; p!=(void*)0; p=p->next)
- if(p->address == address)
- return;
-
- // Create the new node for the linked list
- p = new BreakpointNode;
- p->address=address;
- p->next=(void*)0;
-
- // Put the node at the end of the linked list
- if(tail==(void*)0)
- {
- head=tail=p;
- }
- else
- {
- tail->next=p;
- tail=p;
- }
- return;
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // Delete the breakpoint from the list
- ///////////////////////////////////////////////////////////////////////////////
- int BreakpointList::Delete(unsigned long address)
- {
- BreakpointNode *p,*q;
-
- for(q=(void*)0,p=head; ((p->address!=address) &&
- (p!=(void*)0)); q=p,p=p->next);
-
- if(p!=((void*)0))
- {
- // Unlink the BreakpointNode
- if((p==head) && (p==tail))
- {
- head=tail=(void*)0;
- }
- else if (p==head)
- {
- head=p->next;
- }
- else if(p==tail)
- {
- q->next=(void*)0;
- tail=q;
- }
- else
- {
- q->next=p->next;
- }
-
- // Free the breakpoint node
- delete p;
-
- return(1);
- }
- else
- {
- return(0);
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // Return the number of breakpoints in the list
- ///////////////////////////////////////////////////////////////////////////////
- int BreakpointList::NumberOfBreakpoints()
- {
- BreakpointNode *p;
- int t=0;
-
- for(p=head;p!=(void*)0;p=p->next)
- ++t;
-
- return(t);
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // Get the break point with the given index (1=OK,0=ERROR)
- ///////////////////////////////////////////////////////////////////////////////
- int BreakpointList::GetBreakpoint(unsigned int index, unsigned long& address)
- {
- BreakpointNode *p;
- int t;
-
- for(t=0,p=head;(t<index) && (p!=(void*)0);++t,p=p->next);
-
- if(p!=(void*)0)
- {
- address=p->address;
- return(1);
- }
-
- return(0);
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // Check to see if the given address is a breakpoint (1=YES,0=NO)
- ///////////////////////////////////////////////////////////////////////////////
- int BreakpointList::Check(unsigned long address)
- {
- BreakpointNode *p;
-
- for(p=head;p!=(void*)0;p=p->next)
- if(p->address == address)
- return(1);
-
- return(0);
- }
-
-